﻿using System;
using System.Collections.Generic;

namespace Bilibili.Model.Comment
{
    public sealed class Comment
    {
        public int Action { get; set; }
        public long Rpid { get; set; }
        public long Oid { get; set; }
        public int Type { get; set; }
        public long Mid { get; set; }
        public long Root { get; set; }
        public long Parent { get; set; }
        public int Count { get; set; }
        public int Rcount { get; set; }
        public int Like { get; set; }
        public string RcountStr
        {
            get
            {
                if (Rcount > 10000)
                    return ((double)Rcount / 10000).ToString("0.0") + "万";
                else
                    return Rcount.ToString();
            }
        }
        public string LikeStr
        {
            get
            {
                if (Like > 10000)
                    return ((double)Like / 10000).ToString("0.0") + "万";
                else
                    return Like.ToString();
            }
        }
        public int Floor { get; set; }
        public int State { get; set; }
        public long Ctime { get; set; }
        public string Time
        {
            get
            {
                DateTime dtStart = new DateTime(1970, 1, 1);
                TimeSpan toNow = TimeSpan.FromSeconds(Ctime);
                DateTime dt = dtStart.Add(toNow).ToLocalTime();
                TimeSpan span = DateTime.Now - dt;
                if (span.TotalDays > 7)
                    return dt.ToString("yyyy-MM-dd");
                else if (span.TotalDays > 1)
                    return string.Format("{0}天前", (int)Math.Floor(span.TotalDays));
                else if (span.TotalHours > 1)
                    return string.Format("{0}小时前", (int)Math.Floor(span.TotalHours));
                else if (span.TotalMinutes > 1)
                    return string.Format("{0}分钟前", (int)Math.Floor(span.TotalMinutes));
                else if (span.TotalSeconds >= 1)
                    return string.Format("{0}秒前", (int)Math.Floor(span.TotalSeconds));
                else
                    return "1秒前";
            }
        }
        public string RpidStr { get; set; }
        public CommentMember Member { get; set; }
        public CommentContent Content { get; set; }
        public int LoadPage { get; set; } = 1;
        public string ReplyAt
        {
            get
            {
                return "回复 @" + Member.Uname;
            }
        }
        public string ReplyText { get; set; }
        public bool ShowTop { get; set; } = false;
        public List<Comment> Replies { get; set; } = new List<Comment>();
    }
}